package com.properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import org.junit.Test;

public class PropertiesExe {
	
	public static void testExe() throws FileNotFoundException, IOException {
		Properties p=new Properties();
		p.setProperty("url", "127.0.0.1");
		p.setProperty("user", "admin");
		p.setProperty("password", "123456");
		p.setProperty("port", "3306");
		
		p.store(new FileOutputStream("settings.ini"), "setting");
	//	p.stor
	}
	private static void testRead() throws FileNotFoundException, IOException {
		
		Properties p=new Properties();
		p.load(new FileInputStream("settings.ini"));
		
		//2.
		System.out.println(p.getProperty("user"));
		System.out.println(p.getProperty("password"));
		System.out.println(p.getProperty("url"));
		System.out.println(p.getProperty("port"));
	}
@Test
public void testPP() throws FileNotFoundException, IOException {
	//testExe();
	testRead();
}
}
